module Pan
  
  class FormCallback
    attr_accessor :ids
    def initialize(block)
      @block = block
      @ids = nil
    end
    
    def param_values(session)
      session.params.to_a.select{|a,b| ids.include? a}.sort{|a,b| a.first <=> b.first}.map{|a,b| b}
    end
    
    def invoke(session, arg)
      return unless @block
      vals = param_values(session)
      @block.call(*vals)
    end
  end
  
end
